<?php
Yii::import('application.components.AjaxModel');
class AuctionDataAjax extends AjaxModel{
    public $ver;
    public $type;
    
    protected $_auctionIds;
    
    public function rules(){
        return array(
            array('ids,ver,type','safe'),
        );
    }
    public function setIds($auctionIds){
        $tempAuctionIds = explode('|', $auctionIds);
        return $this->_auctionIds = $tempAuctionIds;
    }
    
    public function getIds(){
        return $this->_auctionIds;
    }
    
    public function run(){    
        $auctionData = new AuctionCacheData();
        $rData = $auctionData->findModifyAllByPkGNC($this->_auctionIds,$this->ver);
        $newData=Yii::app()->tools->modelsToArray($rData,array('id','status','end_time','winner_price','winner_id','winner_name'));
        $this->setResponse('rData',$newData);
        $this->setResponse('t',time());
        $this->setResponse('ver', time());
        
        if (!empty($newData)) {
        	$auctionId = $this->type[1]['auctionId'];
        	$bidHistory=new AuctionHistoryList();
	        $bidHistory->setHistoryKey($auctionId);
	        $rHistory=$bidHistory->getHistoryList();
	        $this->setResponse('rBidhistory',$rHistory);
	        
	        $userId=Yii::app()->user->id;
	        if ($userId) {
	        	$customerBidInfoCache=new customerCacheAuctionBidInfo();
	        	$customerBidInfoCache->customerId=$userId;
	        	$customerBidInfoCache->auctionId=$this->_auctionIds[0];
	        	$customerBidInfoData=$customerBidInfoCache->getItems();
	        	$this->setResponse('rCustomerBifInfo', $customerBidInfoData);
	        }
        }
       
        
        return $this;
    }
}
